home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
081-090
/
amok89
/
gtb-oberon
/
demo
/
fontadapt.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
11KB
|
323 lines
MODULE FontAdapt;
(*
* Source generated with OG 37.11 (3.6.93) by Thomas Igracki
* OG is based on GenOberon V1.0 by Kai Bolay & Jan van den Baard
* GenOberon is based on internal GenOberon by Kai Bolay
* internal GenOberon is based on GenC by Jan van den Baard
*
* GUI Designed by : Kai Bolay
*)
IMPORT
e: Exec, I: Intuition, gt: GadTools, g: Graphics, u: Utility, y: SYSTEM;
CONST
MainHotKeys * = "";
GDGadget00 * = 0;
GDGadget10 * = 1;
GDGadget20 * = 2;
GDGadget30 * = 3;
GDGadget40 * = 4;
GDGadget50 * = 5;
GDGadget60 * = 6;
GDGadget70 * = 7;
GDGadget80 * = 8;
GDGadget90 * = 9;
GDGadget100 * = 10;
GDGadget110 * = 11;
CONST
MainCNT = 12;
MainLeft = 64;
MainTop = 45;
MainWidth = 462;
MainHeight = 102;
VAR
Scr-: I.ScreenPtr;
VisualInfo-: e.APTR;
MainWnd-: I.WindowPtr;
MainGList-: I.GadgetPtr;
MainGadgets*: ARRAY MainCNT OF I.GadgetPtr;
MainMenus-: I.MenuPtr;
MainZoom-: ARRAY 4 OF INTEGER;
Font-: g.TextAttrPtr;
Attr-: g.TextAttr;
FontX, FontY: INTEGER;
OffX, OffY: INTEGER;
TYPE
Gadget500LArray = ARRAY 6 OF e.STRPTR;
CONST
Gadget500Labels = Gadget500LArray (
y.ADR ("This"),
y.ADR ("Is"),
y.ADR ("A"),
y.ADR ("Cycle"),
y.ADR ("Gadget"),
NIL);
VAR
TYPE
MainMArray = ARRAY 27 OF gt.NewMenu;
CONST
MainNewMenu = MainMArray (
gt.title, y.ADR ("Project"), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("New"), y.ADR ("N"), {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Open..."), y.ADR ("O"), {}, y.VAL (LONGSET, 0), NIL,
gt.item, gt.barLabel, NIL, {}, LONGSET {}, NIL,
gt.item, y.ADR ("Save"), y.ADR ("S"), {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Save As..."), y.ADR ("A"), {}, y.VAL (LONGSET, 0), NIL,
gt.item, gt.barLabel, NIL, {}, LONGSET {}, NIL,
gt.item, y.ADR ("Quit"), y.ADR ("Q"), {}, y.VAL (LONGSET, 0), NIL,
gt.title, y.ADR ("Edit"), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Cut"), y.ADR ("X"), {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Copy"), y.ADR ("C"), {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Paste"), y.ADR ("V"), {}, y.VAL (LONGSET, 0), NIL,
gt.item, gt.barLabel, NIL, {}, LONGSET {}, NIL,
gt.item, y.ADR ("Erase"), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.item, gt.barLabel, NIL, {}, LONGSET {}, NIL,
gt.item, y.ADR ("Undo"), y.ADR ("Z"), {}, y.VAL (LONGSET, 0), NIL,
gt.title, y.ADR ("Macro"), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Start Learning"), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Stop Learning"), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Assign Macro..."), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.title, y.ADR ("Settings"), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.item, y.ADR ("Create Icons?"), y.ADR ("I"), {I.checkIt,I.checked,I.menuToggle}, y.VAL (LONGSET, 0), NIL,
gt.item, gt.barLabel, NIL, {}, LONGSET {}, NIL,
gt.item, y.ADR ("Meal"), NIL, {}, y.VAL (LONGSET, 0), NIL,
gt.sub, y.ADR ("Raw"), NIL, {I.checkIt}, y.VAL (LONGSET, 2), NIL,
gt.sub, y.ADR ("Cooked"), NIL, {I.checkIt,I.checked}, y.VAL (LONGSET, 1), NIL,
gt.end, NIL, NIL, {}, LONGSET {}, NIL);
TYPE
MainGTypesArray = ARRAY MainCNT OF INTEGER;
CONST
MainGTypes = MainGTypesArray (
gt.buttonKind,
gt.buttonKind,
gt.buttonKind,
gt.integerKind,
gt.numberKind,
gt.cycleKind,
gt.paletteKind,
gt.scrollerKind,
gt.sliderKind,
gt.stringKind,
gt.textKind,
gt.buttonKind
);
TYPE
MainNGadArray = ARRAY MainCNT OF gt.NewGadget;
CONST
MainNGad = MainNGadArray (
4, 86, 129, 14, y.ADR ("Save First"), NIL, GDGadget00, LONGSET {gt.placeTextIn} ,NIL, NIL,
165, 86, 129, 14, y.ADR ("Continue"), NIL, GDGadget10, LONGSET {gt.placeTextIn} ,NIL, NIL,
328, 86, 129, 14, y.ADR ("Cancel"), NIL, GDGadget20, LONGSET {gt.placeTextIn} ,NIL, NIL,
130, 4, 164, 14, y.ADR ("Integer Gadget"), NIL, GDGadget30, LONGSET {gt.placeTextLeft} ,NIL, NIL,
131, 20, 163, 14, y.ADR ("Number Gadget "), NIL, GDGadget40, LONGSET {gt.placeTextLeft} ,NIL, NIL,
11, 36, 283, 14, NIL, NIL, GDGadget50, LONGSET {} ,NIL, NIL,
12, 52, 282, 28, NIL, NIL, GDGadget60, LONGSET {} ,NIL, NIL,
297, 4, 21, 76, NIL, NIL, GDGadget70, LONGSET {} ,NIL, NIL,
322, 4, 21, 76, NIL, NIL, GDGadget80, LONGSET {} ,NIL, NIL,
346, 4, 105, 14, NIL, NIL, GDGadget90, LONGSET {} ,NIL, NIL,
347, 20, 104, 14, NIL, NIL, GDGadget100, LONGSET {} ,NIL, NIL,
347, 36, 104, 44, y.ADR ("Big Button"), NIL, GDGadget110, LONGSET {gt.placeTextIn} ,NIL, NIL
);
TYPE
MainGTagsArray = ARRAY 48 OF u.Tag;
CONST
MainGTags = MainGTagsArray (
u.done,
u.done,
u.done,
gt.inNumber, 0, gt.inMaxChars, 666, u.done,
gt.nmBorder, I.LTRUE, u.done,
gt.cyLabels, y.ADR (Gadget500Labels[0]), u.done,
gt.paDepth, 2, gt.paIndicatorWidth, 40, u.done,
gt.scTotal, 20, gt.scArrows, 16, I.pgaFreedom, I.lorientVert, I.gaRelVerify, I.LTRUE, u.done,
gt.slMaxLevelLen, 2, gt.slLevelFormat, y.ADR (""), I.pgaFreedom, I.lorientVert, I.gaRelVerify, I.LTRUE, u.done,
gt.stString, y.ADR ("String"), gt.stMaxChars, 256, u.done,
gt.txText, y.ADR ("Text"), gt.txBorder, I.LTRUE, u.done,
u.done
);
PROCEDURE ComputeX (value: INTEGER): INTEGER;
BEGIN
RETURN ((FontX * value) + 4 ) DIV 8;
END ComputeX;
PROCEDURE ComputeY (value: INTEGER): INTEGER;
BEGIN
RETURN ((FontY * value) + 4 ) DIV 8;
END ComputeY;
PROCEDURE ComputeFont (width, height: INTEGER);
BEGIN
Font := y. ADR (Attr);
Font^.name := Scr^.rastPort.font^.message.node.name;
FontY := Scr^.rastPort.font^.ySize;
Font^.ySize := FontY;
FontX := Scr^.rastPort.font^.xSize;
OffX := Scr^.wBorLeft;
OffY := Scr^.rastPort.txHeight + Scr^.wBorTop + 1;
IF (width # 0) AND (height # 0) AND
(ComputeX (width) + OffX + Scr^.wBorRight > Scr^.width) OR
(ComputeY (height) + OffY + Scr^.wBorBottom > Scr^.height) THEN
Font^.name := y.ADR ("topaz.font");
Font^.ySize := 8;
FontY := Font^.ySize;
FontX := Font^.ySize;
END;
END ComputeFont;
PROCEDURE SetupScreen* (): INTEGER; (* $CopyArrays- *)
BEGIN
Scr := I.LockPubScreen ("Workbench"); IF Scr = NIL THEN RETURN 1 END;
ComputeFont (0, 0);
VisualInfo := gt.GetVisualInfo (Scr, u.done);
IF VisualInfo = NIL THEN RETURN 2 END;
RETURN 0;
END SetupScreen;
PROCEDURE CloseDownScreen*;
BEGIN
IF VisualInfo # NIL THEN
gt.FreeVisualInfo (VisualInfo);
VisualInfo := NIL;
END;
IF Scr # NIL THEN
I.UnlockPubScreen (NIL, Scr);
Scr := NIL;
END;
END CloseDownScreen;
PROCEDURE MainRender*;
BEGIN
gt.DrawBevelBox (MainWnd^.rPort,
OffX + ComputeX (5), OffY + ComputeY (1),
ComputeX (453), ComputeY (82),
gt.visualInfo, VisualInfo, u.done);
END MainRender;
PROCEDURE CreateMainGadgets* (): INTEGER;
TYPE
TagArrayPtr = UNTRACED POINTER TO ARRAY MAX (INTEGER) OF u.TagItem;
VAR
ng: gt.NewGadget;
gad: I.GadgetPtr;
help: TagArrayPtr;
ret, lc, tc, lvc, offx, offy: INTEGER;
BEGIN
ComputeFont (MainWidth, MainHeight);
gad := gt.CreateContext (MainGList);
IF gad = NIL THEN RETURN 1 END;
lc := 0; tc := 0; lvc := 0;
WHILE lc < MainCNT DO
ng := MainNGad[lc];
ng.visualInfo := VisualInfo;
ng.textAttr := Font;
ng.leftEdge := OffX + ComputeX (ng.leftEdge);
ng.topEdge := OffY + ComputeY (ng.topEdge);
ng.width := ComputeX (ng.width);
ng.height := ComputeY (ng.height);
help := u.CloneTagItems (y.VAL (TagArrayPtr, y.ADR (MainGTags[tc]))^);
IF help = NIL THEN RETURN 8 END;
gad := gt.CreateGadgetA (MainGTypes[lc], gad, ng, help^);
u.FreeTagItems (help^);
IF gad = NIL THEN RETURN 2 END;
MainGadgets[lc] := gad;
WHILE MainGTags[tc] # u.done DO INC (tc, 2) END;
INC (tc);
INC (lc);
END; (* WHILE *)
RETURN 0;
END CreateMainGadgets;
PROCEDURE OpenMainWindow* (createGads: BOOLEAN): INTEGER;
VAR
offx, offy, ret: INTEGER;
wleft, wtop, ww, wh: INTEGER;
BEGIN
wleft := MainLeft; wtop := MainTop;
ComputeFont (MainWidth, MainHeight);
ww := ComputeX (MainWidth);
wh := ComputeY (MainHeight);
IF wleft + ww + OffX + Scr^.wBorRight > Scr^.width THEN
wleft := Scr^.width - ww;
END;
IF wtop + wh + OffY + Scr^.wBorBottom > Scr^.height THEN
wtop := Scr^.height - wh;
END;
IF createGads THEN
ret := CreateMainGadgets(); IF ret # 0 THEN RETURN ret END;
END;
MainMenus := gt.CreateMenus (MainNewMenu, gt.mnFrontPen, 0, u.done);
IF MainMenus = NIL THEN RETURN 3 END;
IF NOT gt.LayoutMenus (MainMenus, VisualInfo, u.done) THEN RETURN 4 END;
MainZoom[0] := MainLeft;
MainZoom[1] := MainTop;
MainZoom[2] := g.TextLength (y.ADR (Scr^.rastPort), "Font Adapt Test...", 18) + 80;
MainZoom[3] := Scr^.wBorTop + Scr^.rastPort.txHeight + 1;
MainWnd := I.OpenWindowTagsA ( NIL,
I.waLeft, wleft,
I.waTop, wtop,
I.waWidth, ww + OffX + Scr^.wBorRight,
I.waHeight, wh + OffY + Scr^.wBorBottom,
I.waIDCMP, gt.buttonIDCMP+gt.integerIDCMP+gt.numberIDCMP+gt.cycleIDCMP+gt.paletteIDCMP+gt.scrollerIDCMP+gt.arrowIDCMP+gt.sliderIDCMP+gt.stringIDCMP+gt.textIDCMP+LONGSET {I.menuPick,I.closeWindow,I.refreshWindow},
I.waFlags, LONGSET {I.windowDrag,I.windowDepth,I.windowClose,I.sizeBRight,I.sizeBBottom,I.activate},
I.waTitle, y.ADR ("Font Adapt Test..."),
I.waScreenTitle, y.ADR ("GadToolsBox Demo"),
I.waZoom, y.ADR (MainZoom),
I.waGadgets, MainGList,
u.done);
IF MainWnd = NIL THEN RETURN 20 END;
IF NOT I.SetMenuStrip (MainWnd, MainMenus^) THEN RETURN 5 END;
MainRender;
RETURN 0;
END OpenMainWindow;
PROCEDURE CloseMainWindow*;
BEGIN
IF MainMenus # NIL THEN
IF MainWnd # NIL THEN
I.ClearMenuStrip (MainWnd);
END;
gt.FreeMenus (MainMenus);
MainMenus := NIL;
END;
IF MainWnd # NIL THEN
I.CloseWindow (MainWnd);
MainWnd := NIL;
END;
IF MainGList # NIL THEN
gt.FreeGadgets (MainGList);
MainGList := NIL;
END;
END CloseMainWindow;
END FontAdapt.